/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.zrnecko.bowlingnumbers.entity;

import javax.el.ELException;
import org.testng.Assert;
import org.jboss.seam.mock.SeamTest;
import org.testng.annotations.Test;

/**
 *
 * @author zrnecko
 */

@Test(groups = {"entity", "validation"})
public class PinDetailsValidation extends SeamTest {
	@Test(groups = {"positive"})
	public void PerfectGameTest() throws Exception {
		new ComponentTest() {

			@Override
			protected void testComponents() throws Exception {
				String pinDetails = "X|X|X|X|X|X|X|X|X|X;X;X";
				int result = 300;
				setValue("#{game.result}", result);
				setValue("#{game.pinDetails}", pinDetails);
				invokeMethod("#{gamesbean.saveGame}");
				Assert.assertEquals(getValue("#{outGame.pinDetails}"), pinDetails);
				Assert.assertEquals(getValue("#{outGame.result}"), result);
			}
		}.run();
	}

	@Test(groups = {"negative"}, expectedExceptions = {ELException.class})
	public void GibberishTest() throws Exception {
		new ComponentTest() {

			@Override
			protected void testComponents() throws Exception {
				String pinDetails = "adlfjakldfjasldfja41341";
				setValue("#{game.pinDetails}", pinDetails);
				invokeMethod("#{gamesbean.saveGame}");
				Assert.fail();
			}
		}.run();

	}

}
